/*
 * JFrameAbout.java
 *
 * Created on May 15, 2007, 1:09 AM
 */

package info.decamps.m2settings.swing;

import info.decamps.m2settings.Constant;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import javax.swing.JEditorPane;
import javax.swing.text.html.HTMLDocument;

/**
 *
 * @author  regis
 */
public class JFrameLicense extends javax.swing.JFrame {
    
    /** Creates new form JFrameAbout */
    public JFrameLicense() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jLabelProgramname = new javax.swing.JLabel();
        jLabelVersion = new javax.swing.JLabel();
        jScrollPaneLicense = new javax.swing.JScrollPane();
        jEditorPaneHTMLLicense = new javax.swing.JEditorPane();
        jButtonOK = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        jLabelProgramname.setText(java.util.ResourceBundle.getBundle("messages").getString("program_name"));

        jLabelVersion.setText(java.util.ResourceBundle.getBundle("pom").getString("version"));

        jEditorPaneHTMLLicense.setEditable(false);
        jEditorPaneHTMLLicense.setContentType("text/html");
        try {
            jEditorPaneHTMLLicense.read(getHTMLLicense(),null);
        }
        catch (IOException e) {
            jEditorPaneHTMLLicense.setText(e.getMessage());
        }
        jScrollPaneLicense.setViewportView(jEditorPaneHTMLLicense);

        jButtonOK.setText("OK");
        jButtonOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOKActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPaneLicense, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 510, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(jLabelProgramname)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabelVersion))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jButtonOK))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabelProgramname)
                    .add(jLabelVersion))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPaneLicense, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
                .add(6, 6, 6)
                .add(jButtonOK)
                .addContainerGap())
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
        dispose();
    }//GEN-LAST:event_jButtonOKActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new JFrameLicense().setVisible(true);
            }
        });
    }
    
    private InputStream getHTMLLicense() {
        return this.getClass().getResourceAsStream("/LICENSE.html");
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonOK;
    private javax.swing.JEditorPane jEditorPaneHTMLLicense;
    private javax.swing.JLabel jLabelProgramname;
    private javax.swing.JLabel jLabelVersion;
    private javax.swing.JScrollPane jScrollPaneLicense;
    // End of variables declaration//GEN-END:variables
}
